package com.hnkywl.sts.dao.jsgl;

import com.hnkywl.sts.entity.cggl.Wljsdmx;
import net.ruixin.orm.hibernate.SimpleHibernateTemplate;
import org.hibernate.Criteria;
import org.hibernate.criterion.CriteriaSpecification;
import org.hibernate.criterion.Projections;
import org.hibernate.criterion.Property;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * Created by Jerry on 13-10-17.
 */
@Repository
public class WljsdmxDao extends SimpleHibernateTemplate<Wljsdmx, Long> {
    public List<Map> findWljsdDetail(Long wljsdId) {
        Criteria criteria = getSession().createCriteria(this.entityClass)
                .createAlias("cgd", "cgd", CriteriaSpecification.LEFT_JOIN)
                .createAlias("xsd", "xsd", CriteriaSpecification.LEFT_JOIN)
                .createAlias("sydw", "sydw", CriteriaSpecification.LEFT_JOIN)
                .createAlias("fylb", "fylb", CriteriaSpecification.LEFT_JOIN)
                .setProjection(Projections.projectionList()
                        .add(Property.forName("cgd.cgdh").as("cgdh"))
                        .add(Property.forName("xsd.xsdh").as("xsdh"))
                        .add(Property.forName("sydw.id").as("sydw.id"))
                        .add(Property.forName("sydw.qc").as("sydw.qc"))
                        .add(Property.forName("fylb.id").as("fylb.id"))
                        .add(Property.forName("fylb.fykmjc").as("fylb.fykmjc"))
                        .add(Property.forName("jfsl").as("jfsl"))
                        .add(Property.forName("dj").as("dj"))
                        .add(Property.forName("je").as("je"))
                        .add(Property.forName("hdsl").as("hdsl"))
                        .add(Property.forName("hddj").as("hddj"))
                        .add(Property.forName("hdje").as("hdje"))
                        .add(Property.forName("kdse").as("kdse"))
                        .add(Property.forName("se").as("se"))
                        .add(Property.forName("me").as("me"))
                        .add(Property.forName("ce").as("ce"))
                        .add(Property.forName("jsje").as("jsje"))
                        .add(Property.forName("bz").as("bz"))
                ).add(Restrictions.eq("jsd.id", wljsdId))
                .setResultTransformer(CriteriaSpecification.ALIAS_TO_ENTITY_MAP);
        return criteria.list();
    }
}
